package cmd

import (
	"fmt"
	"os"

	"github.com/github-user/hw5/myCobra"
)

var (
	rootCmd = &myCobra.Command{
		Use:   "myApp",
		Short: "myApp is a basic app for go learning",
		Long: `A easy and basic application built with
					  love by fjc in Go.
					  Complete documentation is available at https://gitee.com/Fancylee66/cs_hw/tree/master/%E4%BD%9C%E4%B8%9A%E4%BA%94`,
		Run: func(cmd *myCobra.Command, args []string) {
			// Do Stuff Here
			fmt.Printf("myApp is running...\n")
			if author != "YOUR NAME" {
				fmt.Printf(" created by %s\n", author)
			}

		},
	}

	author string
)

func init() {
	rootCmd.PersistentFlags().StringVarP(&author, "author", "a", "YOUR NAME", "author name for copyright attribution")
	rootCmd.AddCommand(timeCmd)

}

func Execute() {
	if err := rootCmd.Execute(); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
}
